﻿<%@ WebHandler Language="C#" Class="LoginHandler" %>

using System;
using System.Web;
using System.Web.SessionState;
using ACE.Wireless.PhoneBattery.BLL;
using ACE.Wireless.PhoneBattery.Common;
using ACE.Wireless.PhoneBattery.DataModel;

public class LoginHandler : IHttpHandler,IRequiresSessionState {

    /// <summary>
    /// it is used by the ajax
    /// </summary>
    /// <param name="context">the result</param>
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        //get the flag which call function
        string opFlag = Convert.ToString(context.Request["opFlag"]);

        if (opFlag == "1")  //call the logout function
        {
            context.Response.Write(Logout(context));
        }
      
    }
    
     /// <summary>
    /// quit the system
    /// </summary>
    /// <returns></returns>
    public string Logout(HttpContext context)
    {
        try
        {        
            context.Session.Clear();
            context.Session.Abandon();               
            return "OK";
        }
        catch
        {
            return "Logout fail.";
        }
    }   
  
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}